home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / cmds / pmake / lst / RCS / lstLength.c,v < prev    next >
Encoding:
Text File  |  1992-05-19  |  1.3 KB  |  71 lines

  1. head     1.2;
  2. branch   ;
  3. access   ;
  4. symbols  ;
  5. locks    ; strict;
  6. comment  @ * @;
  7.  
  8.  
  9. 1.2
  10. date     88.11.17.20.53.27;  author adam;  state Exp;
  11. branches ;
  12. next     ;
  13.  
  14.  
  15. desc
  16. @@
  17.  
  18.  
  19.  
  20. 1.2
  21. log
  22. @checked in with -k by kupfer at 92.05.18.17.32.42.
  23. @
  24. text
  25. @/*-
  26.  * lstLength.c --
  27.  *    Find the length of a lst
  28.  *
  29.  * Copyright (c) 1988 by the Regents of the University of California
  30.  * Copyright (c) 1988 by Adam de Boor
  31.  *
  32.  * Permission to use, copy, modify, and distribute this
  33.  * software and its documentation for any purpose and without
  34.  * fee is hereby granted, provided that the above copyright
  35.  * notice appears in all copies.  The University of California nor
  36.  * Adam de Boor makes any representations about the suitability of this
  37.  * software for any purpose.  It is provided "as is" without
  38.  * express or implied warranty.
  39.  *
  40.  *
  41.  */
  42. #ifndef lint
  43. static char *rcsid =
  44. "$Id: lstLength.c,v 1.2 88/11/17 20:53:27 adam Exp $ SPRITE (Berkeley)";
  45. #endif lint
  46.  
  47. #include    "lstInt.h"
  48.  
  49. int
  50. Lst_Length(l)
  51.     Lst        l;      /* List whose length is desired */
  52. {
  53.     register ListNode     node;
  54.     register List     list = (List)l;
  55.     register int      len;
  56.  
  57.     if (!LstValid(l)) {
  58.     return -1;
  59.     }
  60.  
  61.     for (len = 0, node = list->firstPtr;
  62.      node != NilListNode;
  63.      len++, node = node->nextPtr) {
  64.     if (node == list->firstPtr && len != 0) {
  65.         break;
  66.     }
  67.     }
  68.     return len;
  69. }
  70. @
  71.